package test.study.cv.ocr.tess4j;

import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import net.sourceforge.tess4j.ITesseract;
import net.sourceforge.tess4j.Tesseract;
import org.junit.Test;

import java.awt.*;
import java.io.File;

@Slf4j
public class Demo {

    private String dir = "D:/idea_workspace/study/cv/study-cv-ocr/src/test/resources/";

    private String inputFile = dir + "chi.png";

    @SneakyThrows
    @Test
    public void test() {
        Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
        //
        ITesseract instance = new Tesseract();
        //语言库位置
        instance.setDatapath("D:/idea_workspace/study/cv/study-cv-ocr/src/test/resources/tess4j");
        instance.setLanguage("chi_sim");
        //
        String res = instance.doOCR(new File(inputFile));
        System.out.println(res);
    }
}
